package handler

import (
	"github.com/zeromicro/go-zero/rest"
	"mall-backend/api/internal/handler/goods"
	"mall-backend/api/internal/svc"
	"net/http"
)

func goodsHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
	server.AddRoutes(
		[]rest.Route{
			{
				Method:  http.MethodGet,
				Path:    "/goods/list",
				Handler: goods.GoodsListHandler(serverCtx),
			},
			{
				Method:  http.MethodGet,
				Path:    "/goods/:id",
				Handler: goods.GoodsDetailHandler(serverCtx),
			},
		},
		rest.WithPrefix("/api/v1"),
	)

	server.AddRoutes(
		[]rest.Route{
			{
				Method:  http.MethodPost,
				Path:    "/goods/add",
				Handler: goods.AddGoodsHandler(serverCtx),
			},
			{
				Method:  http.MethodPut,
				Path:    "/goods/:id",
				Handler: goods.UpdateGoodsHandler(serverCtx),
			},
			{
				Method:  http.MethodDelete,
				Path:    "/goods/:id",
				Handler: goods.DeleteGoodsHandler(serverCtx),
			},
		},
		//rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
		rest.WithPrefix("/api/v1"),
	)
}
